package com.starblink.brand.adapter

import android.view.ViewGroup
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.starblink.android.basic.adapter.BaseVH
import com.starblink.android.basic.extension.dp2px
import com.starblink.basic.style.view.empty.SkEmptyView
import com.starblink.search.result.repository.model.GoodsResultEmptyModel

class GoodsEmptyCell(parent: ViewGroup) :
    BaseVH<GoodsResultEmptyModel>(SkEmptyView(parent.context).apply {
        layoutParams = StaggeredGridLayoutManager.LayoutParams(
            StaggeredGridLayoutManager.LayoutParams.MATCH_PARENT,
            StaggeredGridLayoutManager.LayoutParams.WRAP_CONTENT
        ).apply {
            isFullSpan = true
        }
    }) {

    private val emptyView = itemView as SkEmptyView

    override fun onBind(model: GoodsResultEmptyModel, position: Int) {
        emptyView.setPadding(emptyView.paddingLeft, 40.dp2px(), emptyView.paddingRight, 20.dp2px())
        emptyView.hideText2 = false
        emptyView.text2 = model.emptyTxt2

        model.emptyTxt1?.takeIf { it.isNotEmpty() }?.let {
            emptyView.text1 = model.emptyTxt1
        }
    }

}